<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Menu_control {

	public $CI;

    public function __construct()
    {
        $this->CI =& get_instance();
    }

    //主菜单控制
    public function main($m, $i)
    {
        /***
        $m[array]   : 可访问的主菜单数组
        $i[numeric]   : 主菜单索引值，在../config/site.php下
        ***/
        $menu = $m;
        foreach ($m as $k=>$v)
        {
            if ($i == $v['index'])
            {
                unset($menu[$k]);
                array_unshift($menu, $v);
                break;
            }
        }
        return $menu;
    }

    public function add_sub($sub_menus, $new_menu, $add_line=false)
    {
        if (TRUE == $add_line)
        {
            array_unshift($sub_menus, array('index'=>0));
        }
        array_unshift($sub_menus, $new_menu);
        return $sub_menus;
    }

}

?>